package sm.upgrade.converter;

import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import sm.dam.api.Converter;

public class DisplayIdConverter implements Converter {

	private AtomicInteger atomicInt = new AtomicInteger();

	@Override
	public Object convert(Object value, Map<String, Object> owner) {
		Object newValue = value;

		if (value == null) {
			String screenId = (String) owner.get("screen_id");
			String action = (String) owner.get("action");
			if (action == null) {
				action = "do nothing";
			}
			newValue = screenId + "_" + action + "_"
					+ +atomicInt.incrementAndGet();
		}

		return newValue;
	}

}
